<template>
    <div class="BeCore16">
    </div>
</template>

<style>
.BeCore16 .ivu-form-item {
    margin-bottom: 12px;
}
.more-detail {
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    max-width: 160px;
}
</style>

<script lang="ts">
import { ref } from 'vue'
import { AppModel } from '../../../../model/AppModel';
import { PartESP32 } from '../../../../model/parts/PartESP32';
import { ConnectionStatus } from '../../@beshell/conn-ts/SocketBase';


let model: AppModel
let target: PartESP32


const saveAP = ref(false)
const saveStation = ref(false)

const setWiFiDoing = ref(false)



    // async setWiFi(mode: 'ap'|'station', save: boolean) {
    //     if( !this.$connection.isConnected ){
    //         return
    //     }

    //     this.setWiFiDoing = true

    //     let callback = 'function(){'
    //     if(save) {
    //         callback+= "require('Wifi').save();"
    //     }
    //     if( mode=='ap' && this.target.ap.ip ){
    //         callback+= `require('Wifi').setAPIP({ip:'${this.target.ap.ip}',gw:'${this.target.ap.gw}',netmask:'${this.target.ap.netmask}'});`
    //     }
    //     else if( mode=='station' && !this.target.station.useDHCP  && this.target.station.ip ) {
    //         callback+= `require('Wifi').setIP({ip:'${this.target.station.ip}',gw:'${this.target.station.gw}',netmask:'${this.target.station.netmask}'});`
    //     }
    //     callback+= `resolve(true); }`

    //     let func = mode=='ap'? 'startAP': 'connect'
    //     let code = `require('Wifi').${func}("${this.target[mode].ssid}", {password: "${this.target[mode].password}"}, ${callback})`

    //     if( await this.target.runRemote(code) ) {
    //         (this as any).$Message.info("设置完成", 1000)
    //     }

    //     this.setWiFiDoing = false
    // }

    // async getIP(mode: 'ap'|'station') {
        
    //     this.setWiFiDoing = true

    //     let func = mode=='ap'? 'getAPIP': 'getIP'

    //     let ip: any = await this.target.runRemote(`resolve(require('Wifi').${func}())`)
    //     ; (this as any).$Message.info(`零件IP:${ip.ip}; 网关: ${ip.gw}; 子网掩码: ${ip.netmask}`, 5000)

    //     this.setWiFiDoing = false

    // }



</script>
